<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:c="http://java.sun.com/jsp/jstl/core">
    <ui:composition template="layout.xhtml">
        <ui:define name="body">
            <h:form id="cepForm"  acceptcharset="utf-8">
                <h1 class="title">Escrituras</h1>
                <p:growl id="messages" showDetail="true" autoUpdate="true"  />
                <div class="row">
                    <div class="twelve columns"> 
                        <fieldset>
                            <legend> <h4 style="margin:0 0 10px 0">Visualizando</h4></legend>

                            <div style="float:right;">
                                
                                <p:button icon="ui-icon-pencil" 
                                          value="Editar" 
                                          href="editCep.xhtml?cepEdit=#{managerSearchCep.charterShow.id}"/>
                            </div>

                            <p:panel id="charterPanel" style="background: none; border: none;" 
                                     styleClass="container_24 clearfix ">

                                <p:outputLabel value="Número: " styleClass="grid_3"/>
                                <h:outputText styleClass="grid_8" value="#{managerSearchCep.charterShow.esc}"/>

                                <div class="clear"/>

                                <p:outputLabel value="Tipo Ato: " styleClass="grid_3"/>
                                <h:outputText styleClass="grid_8" value="#{managerSearchCep.charterShow.actCep.description}" />  

                                <p:outputLabel value="Natureza: " styleClass="grid_5"/>
                                <h:outputText styleClass="grid_8" value="#{managerSearchCep.charterShow.natureWriting.description}" /> 

                                <div class="clear"/>

                                <p:outputLabel value="Data Ato: " styleClass="grid_3"/>
                                <h:outputText styleClass="grid_8"  value="#{managerSearchCep.charterShow.dateAct}">
                                    <f:convertDateTime pattern="dd/MM/yyyy"/>
                                </h:outputText>

                                <p:outputLabel value="Valor: " styleClass="grid_5"/>
                                <h:outputText styleClass="grid_8" value="#{managerSearchCep.charterShow.currency}">
                                    <f:convertNumber type="currency" locale="pt,BR"/>
                                </h:outputText>


                                <div class="clear"/>

                                <p:outputLabel value="Livro: " styleClass="grid_3" />
                                <h:outputText styleClass="grid_8" value="#{managerSearchCep.charterShow.book}"/>

                                <p:outputLabel value="Livro Complemento: " styleClass="grid_5"/>
                                <h:outputText styleClass="grid_8" value="#{managerSearchCep.charterShow.bookComp}"/> 

                                <div class="clear"/>

                                <p:outputLabel value="Folha: " styleClass="grid_3" />
                                <h:outputText styleClass="grid_8" value="#{managerSearchCep.charterShow.leaf}"/> 

                                <p:outputLabel value="Folha Complemento: " styleClass="grid_5"/>
                                <h:outputText styleClass="grid_8" value="#{managerSearchCep.charterShow.leafComp}"/> 

                                <div class="clear"/>

                                <p:outputLabel value="Cidade: " styleClass="grid_3"/>
                                <h:outputText styleClass="grid_8" value="#{managerSearchCep.charterShow.city.name}"/>  


                                <div class="clear"/>

                                <p:outputLabel value="Objeto: " styleClass="grid_3"/>
                                <h:outputText cols="100" rows="4" 
                                              styleClass="grid_20" value="#{managerSearchCep.charterShow.description}"/> 

                            </p:panel>


                            <fieldset>
                                <legend> <h4 style="margin:0 0 10px 0">Partes</h4></legend>

                                <p:dataTable value="#{managerSearchCep.charterShow.parts}"
                                             emptyMessage="Nenhum registro encontrado"
                                             id="dataTableParts" var="partTable">
                                    <f:facet name="header">
                                        Partes
                                    </f:facet>
                                    <p:column headerText="Nome" width="550">
                                        #{partTable.people.name}
                                    </p:column>

                                    <p:column headerText="Documento">
                                        #{partTable.people.cpf}
                                        #{partTable.people.cnpj}
                                    </p:column>

                                    <p:column headerText="Qualidade">
                                        #{partTable.partQuality.description}
                                    </p:column>

                                </p:dataTable>

                            </fieldset>
                            <fieldset>
                                <legend> <h4 style="margin:0 0 10px 0">Selos</h4></legend>

                                <p:dataTable id="dataTableStamps"
                                             value="#{managerSearchCep.charterShow.stamp}"
                                             var="stampTable"
                                             emptyMessage="Nenhum registro encontrado" >
                                    <f:facet name="header">
                                        Selos
                                    </f:facet>
                                    <p:column headerText="Série">
                                        #{stampTable.serie}
                                    </p:column>
                                    <p:column headerText="Número">
                                        #{stampTable.number}
                                    </p:column>
                                    <p:column headerText="Tipo">
                                        #{stampTable.typeStamp.name}
                                    </p:column>

                                </p:dataTable>
                            </fieldset>
                            <br/>

                            <fieldset>
                                <legend> <h4 style="margin:0 0 10px 0">Anexos</h4></legend>
                                <ui:repeat  value="#{managerSearchCep.charterShow.annex}" var="a">

                                    <h:outputLink  
                                        value="#{a.type ne 'application/pdf' ? 'viewImage':'show'}" 
                                        title="#{a.description}"  target="_blank"  >

                                        <div style="text-align: center; width: 20%;" class="grid_4">

                                            <p:graphicImage styleClass="image grid_3" rendered="#{a.type ne 'application/pdf'}"
                                                            style="margin-left:1%; width: 100px;"
                                                            url="show/?annex=#{a.id}" />

                                            <p:outputLabel  value="#{a.description.length() ge 10 ? a.description.substring(0, 10).concat('...') : 
                                                                     a.description.replace('.png','').replace(' ','_')}" 
                                                            style="margin-left:1%; width: 100px;" rendered="#{a.type ne 'application/pdf'}"/>

                                            <p:graphicImage styleClass="image grid_3" rendered="#{a.type eq 'application/pdf'}"
                                                            style="margin-left:1%; width: 100px;" 
                                                            url="assets/images/pdf.jpeg" />


                                            <p:outputLabel  value="#{a.description.length() ge 10 ? a.description.substring(0, 10).concat('...') : 
                                                                     a.description.replace('.pdf','').replace(' ','_')}" 
                                                            style="margin-left:1%; width: 100px;" rendered="#{a.type eq 'application/pdf'}"/>
                                        </div>
                                        <f:param name="annex" value="#{a.id}"/>
                                    </h:outputLink>

                                </ui:repeat>
                                <br/>
                            </fieldset>

                            <div class="buttonAction">
                                <p:button value="Voltar" href="searchcep.xhtml" icon="ui-icon-arrowreturnthick-1-w" />
                            </div >
                        </fieldset>
                    </div>
                </div>

            </h:form>
        </ui:define>
    </ui:composition>

</html>